package com.ssyt.yt1.day10.adapter;

/**
 * 插座
 * 
 * @author Administrator
 *
 */
class Socket {

	public void plugin(Plug plug) {
		plug.connect();
	}
}

/**
 * 插头
 * 
 * @author Administrator
 *
 */
interface Plug {

	void connect();
}

/**
 * 二孔插头
 * 
 * @author Administrator
 *
 */
class TwoHolePlug implements Plug {

	@Override
	public void connect() {
		System.out.println("二孔插头...");
	}
}

/**
 * 特殊的三孔插头
 * 
 * @author Administrator
 *
 */
class ThreeHolePlug {

	public void connection() {
		System.out.println("三孔插头...");
	}
}

/**
 * 适配器模式二：类适配（通过继承方式实现）
 * 
 * @author Administrator
 *
 */
class PlugAdapter extends ThreeHolePlug implements Plug {

	@Override
	public void connect() {
		super.connection();
	}
}

public class AdapterDemo2 {

	public static void main(String[] args) {
		new Socket().plugin(new PlugAdapter());
	}
}
